<%@page import="beans.Task"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link href="<%=path%>/admin/css/haiersoft.css" rel="stylesheet"
	type="text/css" />
<link href="<%=path%>/admin/css/print.css" rel="stylesheet"
	type="text/css" media="print" />
<script src="<%=path%>/admin/js/jquery-1.10.1.min.js"></script>
<script src="<%=path%>/admin/js/side.js" type="text/javascript"></script>
<script src="<%=path%>/admin/js/function.js" type="text/javascript"></script>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script>
<![endif]-->
<script type="text/javascript">
$(function() {
	// 隔行显示，鼠标停留显示整行
	$('tbody>tr:not(#search)').each(function(){
			this.onmouseover = function() {
				this.style.backgroundColor = '#E0FFFF';
			};
	});
	$('tbody>tr:odd:not(#search)').each(function(){
		this.onmouseout = function() {
			this.style.backgroundColor = '#fff';
		};
	});
	$('tbody>tr:even:not(#search)').each(function(){
		this.onmouseout = function() {
			this.style.backgroundColor = '#edf5ff';
		};
		this.style.backgroundColor = '#edf5ff';
	});
});
</script>
</head>

<body>
	<!-- MainForm -->
	<div id="MainForm">
		<div class="form_boxA">
			<form id="searchForm" action="TaskServlet" method="post">
				<table style="width: 500px">
					<tr id="search">
						<td><label for="id">任务编号:</label></td>
						<td><input id="id" name="id" pattern="[0-9]{1,}" value="${id }"
							placeholder="请输入数字编号！" type="text" /></td>
						<td><input id="page" name="page" placeholder="Text"
							type="hidden" value="1" /> <input type="submit" value="搜索" /></td>
					</tr>
				</table>
			</form>
			<h2>任务信息列表</h2>
			<table>
				<thead>
					<tr>
						<th>编号</th>
						<th>顾客名称</th>
						<th>顾客电话</th>
						<th>任务信息</th>
						<th>佣金</th>
						<th>地址</th>
						<th>任务时间</th>
						<th>任务状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<%
						@SuppressWarnings("unchecked")
						List<Task> tasks = (List<Task>) request.getAttribute("tasks");
						for (Task task : tasks) {
							if (task == null)
								break;
					%>
					<tr>
						<td><%=task.getId()%></td>
						<td><%=task.getCustomer().getUsername()%></td>
						<td><%=task.getCustomer().getTel()%></td>
						<td><%=task.getMessage()%></td>
						<td><%=task.getMoney()%></td>
						<td><%=task.getAddress()%></td>
						<td><%=task.getTime()%></td>
						<td><%=task.getStatus()%></td>
						<td><a
							href="<%=path%>/TaskOperationServlet?operation=alt&id=<%=task.getId()%>">修改</a>
							| <a href="javascript:void(0)"
							onclick="deleteTr(this,'TaskOperationServlet','<%=path%>')">删除</a></td>
					</tr>
					<%
						}
					%>
				</tbody>
			</table>
			<script type="text/javascript">
				function toPage(pageNum) {
					var page = document.getElementById('page');
					var searchForm = document.getElementById('searchForm');
					var count = $
					{
						count
					}
					;
					var maxPage = parseInt(count / 15) + 1;
					if (pageNum < 1)
						page.value = 1;
					else if (pageNum > maxPage)
						page.value = maxPage;
					else
						page.value = parseInt(pageNum);
					searchForm.submit();
				}
			</script>
			<!-- PageNum -->
			<ul id="PageNum">
				<li><a href="javascript:toPage(1)">首页</a></li>
				<li><a href="javascript:toPage(${page }-1)">上一页</a></li>
				<li><a href="javascript:void(0)">${page }</a></li>
				<li><a href="javascript:toPage(${page }+1)">下一页</a></li>
				<li><a href="javascript:toPage(${count/5+1 })">尾页</a></li>
			</ul>
			<!-- /PageNum -->
			<p class="msg">共找到${count }条记录，当前显示从第${(page-1)*5+1 }条至第${page*5>count?count:page*5 }条</p>
		</div>
	</div>
	<!-- /MainForm -->

</body>
</html>